package com.atguigu.gulimall.member.web;

import com.atguigu.common.utils.Constant;
import com.atguigu.common.utils.R;
import com.atguigu.gulimall.member.feign.OrderFeignService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;

import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.Map;

/**
 * @author liuq
 * @version 1.0
 * @description:
 * @date 2021/2/25 22:24
 */
@Controller
public class MemberWebController {

    @Autowired
    private OrderFeignService orderFeignService;

    @GetMapping("/memberOrderList")
    public String memberOrderListPage(@RequestParam(value = "pageNum", defaultValue = "1") String pageNum, Model model, HttpServletRequest request){
        // 可以从request中获取到支付宝给我们返回回来的数据
        // 验证签名的方式验证是否是支付宝的签名

        Map<String, Object> page = new HashMap<>();
        page.put(Constant.PAGE, pageNum);
        R r = orderFeignService.listWithItem(page);
        model.addAttribute("orders", r);
        return "orderList";
    }
}
